<?php
include('includes/header.php');
?>

    <div id="main">
    <?php
    //only need to check the session or a variable
//     echo "<table>";
//     foreach ($_SERVER as $k => $s){
//     	echo "<tr style='text-align:left;'><td>[".$k."]</td><td>".$s."</td></tr>";
//     }
//     echo "</table>";
    echo "<p>Welcome!!!</p>";
    if ($authenticated){
        //success login, next authorize user
        if ($authorized){
            echo "Username: ".$username . "<br />Role: ". $role;
            //continue the rest of the code, here...

            
            
            } else {
            echo "You are not authorized to view this page!!";
        }
    } else {
        //try to login, but failed login
        if ($_GET['login']=='failed'){
            echo "<script type=\"text/javascript\">loginerror('login=failed&oriloc=".$_SERVER['PHP_SELF']."')</script>";
        } else {
            //not login yet
            echo "<p>Please Login</p>";
        }
    }
    ?>
    </div>
<?php include('includes/footer.php'); ?>